﻿using System;
using System.Collections.Generic;
//using System.Linq;
using System.Text;

namespace DBSourceToolsLib.FileComparer
{
    public class DCFile : IDCFileObject
    {
        private string m_FileName;
        private string m_BaseDir;
        protected  List<IDCFileObject> m_FileList = new List<IDCFileObject>();

        public DCFile(string strFileName, string strBaseDir, DirectoryList oDirectoryComparer)
        {
            this.m_FileName = strFileName;
            this.m_BaseDir = strBaseDir;
            oDirectoryComparer.AddDCFileObject(this);
        }

        #region IDCFileObject Members

        public bool isFile()
        {
            return m_FileList.Count == 0;
        }

        public string GetRelativeFileName()
        {
            return m_FileName.Substring(m_BaseDir.Length);
        }

        public string GetBaseDirectory()
        {
            return m_BaseDir;
        }

        public System.Collections.IEnumerator GetFiles()
        {
            throw new NotImplementedException();
        }


        public virtual void Add(IDCFileObject oDCFileObject)
        {
            throw new NotImplementedException();
        }

        #endregion

        #region IDCFileObject Members


        public void Print()
        {
            System.Console.WriteLine(this.m_BaseDir 
                + (this.isFile() ? " F " : " D ")
                + this.GetRelativeFileName());
            foreach (IDCFileObject oFileObject in this.m_FileList)
            {
                oFileObject.Print();
            }
        }

        public string GetFullPath()
        {
            return this.m_FileName;
        }

        #endregion
    }
}
